package com.example.sfm.controller.admin;


import com.example.sfm.constant.MessageConstants;
import com.example.sfm.pojo.dto.AdminLoginDto;
import com.example.sfm.result.Result;
import com.example.sfm.service.IAdminService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @author sfm
 * @since 2025-03-08
 */
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "管理员相关接口", description = "管理员相关接口")
public class AdminController {

    private final IAdminService adminService;


    /**
     * 管理员登录
     *
     * @param loginDto dto
     * @return token
     */
    @Operation(summary = "管理员登录", description = "管理员登录")
    @PostMapping("/login")
    public Result<?> login(@RequestBody @Validated AdminLoginDto loginDto) {
        log.info("管理员登录:{}", loginDto);
        return Result.success(adminService.login(loginDto), MessageConstants.LOGIN_SUCCESS);
    }
}
